<template>
  <div>
    <!-- 导航菜单 -->
    <Menu :open-names="[menuItem1]" :active-name="menuItem" theme="light" width="auto" :accordion="true">
      <MenuItem name="/generalSituationOf" to="/generalSituationOf">
        <Icon type="ios-navigate"/> 概况
      </MenuItem>
      <Submenu :name="item.id" v-for="item in list" :key="item.id">
        <template slot="title">
          <Icon :type="item.icon"></Icon>{{ item.title }}</template
        >
        <MenuItem v-for="ele in item.children" :key="ele.id" :name="ele.path" :to="ele.path">{{
          ele.title
        }}</MenuItem>
      </Submenu>
    </Menu>
  </div>
</template>

<script>
export default {
  created(){
    this.activeName()
  },
  data() {
    return {
      menuItem:"/generalSituationOf",
      menuItem1:"",
      list: [
        {
          id: 2,
          title: "商品",
          icon: "ios-navigate",
          children: [
            {
              id: 2.1,
              title: "商品列表",
              path:'/warehouse'
            },
            {
              id: 2.2,
              title: "草稿箱",
              path:'/draftBox'
            },
            {
              id: 2.3,
              title: "分组管理",
              path:'/groupManagement'
            },
            {
              id: 2.4,
              title: "标签管理",
              path:'/labelManagement'
            },
            {
              id: 2.5,
              title: "回收站",
              path:'/labelManagement'
            },
            {
              id: 2.6,
              title: "预警货品",
              path:'/labelManagement'
            },
            {
              id: 2.7,
              title: "资质申请",
              path:'/labelManagement'
            },
            {
              id: 2.8,
              title: "品牌申请",
              path:'/labelManagement'
            },
          ],
        },
        {
          id: 3,
          title: "交易",
          icon: "ios-navigate",
          children: [
            {
              id: 3.1,
              title: "所有订单",
              path:'/labelManagement'
            },
            {
              id: 3.2,
              title: "维权订单",
              path:'/labelManagement'
            },
            {
              id: 3.3,
              title: "物流管理",
              path:'/labelManagement'
            },
            {
              id: 3.4,
              title: "结算管理",
              path:'/labelManagement'
            }
          ],
        },
        {
          id: 4,
          title: "统计",
          icon: "ios-navigate",
          children: [
            {
              id: 4.1,
              title: "店铺概况",
              path:'/labelManagement'
            },
            {
              id: 4.2,
              title: "运营报告",
              path:'/labelManagement'
            },
            {
              id: 4.3,
              title: "商品分析",
              path:'/labelManagement'
            },
            {
              id: 4.4,
              title: "流量统计",
              path:'/labelManagement'
            },
            {
              id: 4.5,
              title: "交易统计",
              path:'/labelManagement'
            }
          ],
        },
        {
          id: 5,
          title: "会员",
          icon: "ios-navigate",
          children: [
            {
              id: 5.1,
              title: "用户管理",
              path:'/labelManagement'
            },
            {
              id: 5.2,
              title: "角色权限",
              path:'/labelManagement'
            }
          ],
        },
      ],
    };
  },
  methods:{
    activeName(){
      let URL=document.URL
        if (URL.indexOf("/generalSituationOf") !== -1) {
        this.defaultActive = "/generalSituationOf";
        return;
      }
      this.list.map((item) => {
        if (item.children !== undefined) {
          item.children.map((it) => {
            if (URL.indexOf(it.path) !== -1) {
              this.menuItem = it.path;
              this.menuItem1 = item.id
            }
          });
        }
      });
    }
  }
};
</script>

<style lang="scss">
</style>